﻿
namespace Edu.Technion.CSE.OpenUnit4.CollectionsLib
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Node<T> : IListNode<T>
    {
        // Members
        private T info;
        private Node<T> next;

        // Constructors

        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        public Node(T info)
        {
            this.info = info;
            this.next = null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <param name="next"></param>
        public Node(T info, Node<T> next)
        {
            this.info = info;
            this.next = next;
        }

        // Public Methods

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public T GetInfo()
        {
            return info;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Node<T> GetNext()
        {
            return next;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="newInfo"></param>
        public void SetInfo(T newInfo)
        {
            info = newInfo;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="newNext"></param>
        public void SetNext(Node<T> newNext)
        {
            next = newNext;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return info.ToString();
        }
    }
}
